<%@ page import="com.NewsService.NewsService" %>
<%@ page import="com.NewsServiceImpl.NewsServiceImpl" %>
<%@ page import="com.entity.News" %>
<%@ page import="javax.naming.Context" %>
<%@ page import="java.util.Date" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<html>
<head>
    <title>Title</title>
</head>
<body>
<%
      /*
        NewsService service = new NewsServiceImpl();
        News news= service.ServiceSselectById(6);
        request.setAttribute("news",news);
        request.setAttribute("username","张三");
        */


    News news = new News();
    news.setContent("dddd");
    news.setTitle("ddd");
    news.setCreatedate(new Date());

    int[] num = new int[5];
    num[0] = 1;
    num[1] = 2;
    num[2] = 3;
    session.setAttribute("num", num);
    session.setAttribute("news", news);
%></>
<table style="border-style: solid;border: 1px">
    <th>
    <td>标题</td>
    <td>内容</td>
    </th>
    <tr>
        <%--
        ${requestScope.xxx}:针对性的从request中取值
        --%>
        <td>${requestScope.num[0]}</td>
        <%--
          ${num[0]}:它会依次从内置对象中，去拿。
         --%>
        <td>${news.content}</td>
    </tr>
    <tr>
        <td>姓名：${username.equals("张三")?"是真的":"加的"}</td>
    </tr>
    <%--<tr>
        <td>数组：${num[0]}</td>
    </tr>--%>

    <%--使用 jstl标签呢--%>
    <hr/>
    <%--输出--%>
    <c:out value="${news.content}"></c:out>
    <%--设置变量和对象属性--%>
    <c:set var="name" value="123" scope="request"></c:set>
    <c:set property="content" target="${news}" value="vdzvfs"></c:set>

    <c:remove var="name"></c:remove>
    <%--输出--%>
    <c:out value="${news.content}"></c:out>
    <%--迭代标签--%>
    <c:forEach var="d" items="${num}" varStatus="id">
        ${id.index}====${d}
        <input type="text" value="${d}"> </input>
    </c:forEach>
    <%--条件标签--%>
    <c:if test="${news.content !=null}">
        <lable><a href>${news.content}</a></lable>
    </c:if>
    <c:if test="${news.content ==null}">
        <lable><a href>请登录</a></lable>
    </c:if>
   <%--超链接标签--%>
   <%-- <c:url value="http://localhost:8080"></c:url>
    <c:param name="na" value="12"></c:param>--%>

    <%--格式化标签--%>
    <fmt:formatDate value="${news.createdate}" pattern="yyyy-MM-dd"></fmt:formatDate>

</table>
</body>
</html>
